package com.xbongbong.saas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * 应用模块名称<p>
 * 代码描述<p>
 * Company: 逍邦网络科技有限公司<p>
 *
 * @author chenshan
 * @version v1.0
 * @since 2019-11-22 15:35
 */
@Getter
public enum DetailTabScriptEnum {
	CUSTOMER_PAYMENT_MANAGEMENT(XbbRefTypeEnum.CUSTOMER_MANAGEMENT,"payment","payment","enum.detailTabScript.oldName.customer_payment_management","paymentManagement","paymentManagement","enum.detailTabScript.newName.customer_payment_management"),
	
	CONTRACT_PAYMENT_MANAGEMENT(XbbRefTypeEnum.CONTRACT,"payment","payment","enum.detailTabScript.oldName.contract_payment_management","paymentManagement","paymentManagement","enum.detailTabScript.newName.contract_payment_management"),

	PURCHASE_PAY_PLAN_MANAGEMENT(XbbRefTypeEnum.PURCHASE, "supplierPayment","supplierPayment","enum.detailTabScript.oldName.purchase_pay_plan_management","payPlanManagement","payPlanManagement","enum.detailTabScript.newName.purchase_pay_plan_management"),

	SUPPLIER_PAY_PLAN_MANAGEMENT(XbbRefTypeEnum.SUPPLIER, "supplierPayment","supplierPayment","enum.detailTabScript.oldName.supplier_pay_plan_management","payPlanManagement","payPlanManagement","enum.detailTabScript.newName.supplier_pay_plan_management"),
	;
	/**
	 *关联业务
	 */
	private XbbRefTypeEnum xbbRefTypeEnum;
	/**
	 *旧attr值
	 */
	private String oldAttr;
	/**
	 *旧key值
	 */
	private String oldKey;
	/**
	 *旧name值
	 */
	private String oldName;
	/**
	 * 新attr值
	 */
	private String newAttr;
	/**
	 *新key值
	 */
	private String newKey;
	/**
	 *新name值
	 */
	private String newName;
	
	
	DetailTabScriptEnum(XbbRefTypeEnum xbbRefTypeEnum, String oldAttr, String oldKey, String oldName, String newAttr, String newKey, String newName) {
		this.xbbRefTypeEnum = xbbRefTypeEnum;
		this.oldAttr = oldAttr;
		this.oldKey = oldKey;
		this.oldName = oldName;
		this.newAttr = newAttr;
		this.newKey = newKey;
		this.newName = newName;
		
	}
	
	public static List<DetailTabScriptEnum> getByBusinessType(XbbRefTypeEnum xbbRefTypeEnum) {
		List<DetailTabScriptEnum> detailTabScriptEnumList = new ArrayList<>();
		for ( DetailTabScriptEnum item : values() ) {
			if ( Objects.equals(item.getXbbRefTypeEnum(), xbbRefTypeEnum) ) {
				detailTabScriptEnumList.add(item);
			}
		}
		return detailTabScriptEnumList;
	}

	public String getOldName() {
		return I18nMessageUtil.getMessage(oldName);
	}

	public String getNewName() {
		return I18nMessageUtil.getMessage(newName);
	}
}
